# coding=UTF-8
import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import math
import Gesture.rotation

from mpl_toolkits.mplot3d import Axes3D
def data_read(path):
    data=pd.read_csv(path)
    D=[]
    F=[]
    for j in range(len(data["bone_pos"])):
        Data = data["bone_pos"][j].replace("[[", "").replace("[", "").replace("]", "").replace("(", "").replace(")","").replace("',", "").split("'")[1:-1]

        for i in range(len(Data)):
            Data[i]=[float(k) for k in Data[i].split(",")]

        D.append(Data)

    tp=[False,True,False]*20
    D=np.array(D)
    for i in D:
        F.append(i[tp])

    F=np.array(F)
    # F=rotation.deal_Rotation(F)
    return data['label'],F,F[:,5]-F[:,4]
#1手 5指头 4骨头

#fig = plt.figure()

# for i in range(0,600):
#     B=F[i]
#     # ax1 = plt.axes(projection='3d')
#     ax2=plt.axes()
#     # ax1.scatter(B[:,0], B[:,1], B[:,2])
#     ax2.scatter(B[:,0],B[:,2])
#     # ax2.scatter(B[:,0][4],B[:,2][4])
#     # ax2.scatter(B[:,0][0],B[:,2][0])
# plt.show()

######手掌不一致情况
#提取手掌长度
# length=data['length']
# width=data['width']
# LK=[]
# #手掌长度归一化
# for i in range(len(length)):
#     L=length[i].replace("[","").replace("]","").split(",")
#     L=[float(k) for k in L]
#     LK.append(L)
